//Created by Erin Cassese
//For "Partisan Dehumanization in American Politics" in Political Behavior 
//Analysis of Student Data
///March 26, 2019

clear
* set file path here: cd " "
use "Student Study Data.dta"

*Data for Figure 1A-C

* Figure 1A 
mean HU_dem if pid3==1
mean HU_dem if pid3==3
mean HU_rep if pid3==1
mean HU_rep if pid3==3

* Figure 2A
mean HN_dem if pid3==1
mean HN_dem if pid3==3
mean HN_rep if pid3==1
mean HN_rep if pid3==3

* Figure 3A 
mean ascent_demRS if pid3==1
mean ascent_demRS if pid3==3
mean ascent_repRS if pid3==1
mean ascent_repRS if pid3==3

* Table A1 Models - Online Appendix 

eststo clear
eststo: regress HN_dem i.pid2##c.identity age female nonwhite, robust
eststo: regress HU_dem i.pid2##c.identity age female nonwhite, robust 
eststo: regress ascent_demRS i.pid2##c.identity age female nonwhite, robust

eststo: regress HN_rep i.pid2##c.identity age female nonwhite, robust
eststo: regress HU_rep i.pid2##c.identity age female nonwhite, robust
eststo: regress ascent_repRS i.pid2##c.identity age female nonwhite, robust
esttab using TableA1.rtf, b(2) se(2) ar2 star(+ 0.10 * 0.05 ** .01 *** .001)
eststo clear

* Robustness Check - Party Affect as a Covariate

eststo clear
eststo: regress HN_dem i.pid2##c.identity age female nonwhite diff_therm_partiesS, robust
eststo: regress HU_dem i.pid2##c.identity age female nonwhite diff_therm_partiesS, robust 
eststo: regress ascent_demRS i.pid2##c.identity age female nonwhite diff_therm_partiesS, robust

eststo: regress HN_rep i.pid2##c.identity age female nonwhite diff_therm_partiesS, robust
eststo: regress HU_rep i.pid2##c.identity age female nonwhite diff_therm_partiesS, robust
eststo: regress ascent_repRS i.pid2##c.identity age female nonwhite diff_therm_partiesS, robust
esttab using Table_RCheck1.rtf, b(2) se(2) ar2 star(+ 0.10 * 0.05 ** .01 *** .001)
eststo clear

* Figure 2A (make these figures, then "fig2a_d.gph" "fig2a_e.gph" & "fig2a_f.gph" from the MTurk data and create composite, using the same file path)

eststo: regress HU_dem i.pid2##c.identity age female nonwhite, robust 
margins pid2, at(identity=(-1.5(.5)1.5)) vsquish
marginsplot, recastci(rarea)  title ("Animalistic (Student Sample)", size(medsmall)) xtitle("Identity Strength") ytitle("Animalistic Traits") ylabel(-1.5(.5)1.5) 
graph save "fig2a_a.gph" 

eststo: regress HN_dem i.pid2##c.identity age female nonwhite, robust
margins pid2, at(identity=(-1.5(.5)1.5)) vsquish
marginsplot, recastci(rarea)  title ("Mechanistic (Student Sample)", size(medsmall)) xtitle("Identity Strength") ytitle("Mechanistic Traits") ylabel(-1.5(.5)1.5) 
graph save "fig2a_b.gph" 

eststo: regress ascent_demRS i.pid2##c.identity age female nonwhite, robust
margins pid2, at(identity=(-1.5(.5)1.5)) vsquish
marginsplot, recastci(rarea)  title ("Blatant (Student Sample)", size(medsmall)) xtitle("Identity Strength") ytitle("Blatant Dehumanization") ylabel(-1.5(.5)1.5) 
graph save "fig2a_c.gph" 

*grc1leg  "fig2a_a.gph" "fig2a_b.gph" "fig2a_c.gph" "fig2a_d.gph" "fig2a_e.gph" "fig2a_f.gph",  rows(2) title("A. Evaluations of Democrats by Partisans in Two Samples")

* Figure 2B (make these figures, then "fig2b_d.gph" "fig2b_e.gph" & "fig2b_f.gph" from the MTurk data and create composite)

eststo: regress HU_rep i.pid2##c.identity age female nonwhite, robust
margins pid2, at(identity=(-1.5(.5)1.5)) vsquish
marginsplot, recastci(rarea)  title ("Animalistic (Student Sample)", size(medsmall)) xtitle("Identity Strength") ytitle("Animalistic Traits") ylabel(-1.5(.5)1.5) 
graph save "fig2b_a.gph" 

eststo: regress HN_rep i.pid2##c.identity age female nonwhite, robust
margins pid2, at(identity=(-1.5(.5)1.5)) vsquish
marginsplot, recastci(rarea)  title ("Mechanistic (Student Sample)", size(medsmall)) xtitle("Identity Strength") ytitle("Mechanistic Traits") ylabel(-1.5(.5)1.5) 
graph save "fig2b_b.gph" 

eststo: regress ascent_repRS i.pid2##c.identity age female nonwhite, robust
margins pid2, at(identity=(-1.5(.5)1.5)) vsquish
marginsplot, recastci(rarea)  title ("Blatant (Student Sample)", size(medsmall)) xtitle("Identity Strength") ytitle("Blatant Dehumanization") ylabel(-1.5(.5)1.5) 
graph save "fig2b_c.gph" 
eststo clear

*grc1leg  "fig2b_a.gph" "fig2b_b.gph" "fig2b_c.gph" "fig2b_d.gph" "fig2b_e.gph" "fig2b_f.gph",  rows(2) title("A. Evaluations of Republicans by Partisans in Two Samples")

* Table A3 - Online Appendix

* Panel A 
pwcorr identity HU_dem HN_dem ascent_demRS dem_therm if pid3==3, sig

* Panel C 
pwcorr identity HU_rep HN_rep ascent_repRS rep_therm if pid3==1, sig

* Table A4 Models - Online Appendix 

eststo clear
eststo: regress dem_social_distance identity diff_ascent_partiesS diff_therm_partiesS age female nonwhite if pid3==3
eststo: regress rep_social_distance identity  diff_ascent_partiesS diff_therm_partiesS age female nonwhite if pid3==1
eststo: regress moral_distance_parties identity diff_ascent_partiesS diff_therm_partiesS age female nonwhite if pid3==3
eststo: regress moral_distance_parties identity  diff_ascent_partiesS diff_therm_partiesS age female nonwhite if pid3==1
esttab using TableA4.rtf, b(2) se(2) ar2 star(+ 0.10 * 0.05 ** .01 *** .001)

* Data for Figure 3

eststo clear
eststo: regress dem_social_distance identity  diff_ascent_partiesS diff_therm_partiesS age female nonwhite  if pid3==3
margins, at(diff_ascent_partiesS=(-.830402 2.517638)) level(90)  contrast(atjoint effect) 
eststo: regress rep_social_distance identity  diff_ascent_partiesS diff_therm_partiesS age female nonwhite  if pid3==1
margins, at(diff_ascent_partiesS=(-.830402 2.517638)) level(90)  contrast(atjoint effect) 
eststo: regress moral_distance_parties identity diff_ascent_partiesS diff_therm_partiesS age female nonwhite if pid3==3
margins, at(diff_ascent_partiesS=(-.830402 2.517638)) level(90)  contrast(atjoint effect)  
eststo: regress moral_distance_parties identity  diff_ascent_partiesS diff_therm_partiesS age female nonwhite if pid3==1
margins, at(diff_ascent_partiesS=(-.830402 2.517638)) level(90) contrast(atjoint effect) 
	
* Table A6 - Online Appendix 

mean age
tab female
tab white
tab black
tab hispanic
tab asian
tab other
tab pid3 
tab ideo3 
tab follow


